package com.test.designPattern.ch15;

import com.test.designPattern.ch15.order.Order;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName Broker
 * @Description 命令调用类
 * @Author 维康
 * @Date 2018/6/11 15:39
 * @Version 1.0
 **/
public class Broker {
    private List<Order> orderList = new ArrayList<Order>();

    /**
     * @Description: 接收命令
     * @param order
     * @author Chenwk
     * @date 2018/6/11 15:44
     **/
    public void takeOrder(Order order){
        orderList.add(order);
    }

    /**
     * @Description: 执行命令
     * @author Chenwk
     * @date 2018/6/11 15:45
     **/
    public void placeOrders(){
        for (Order order : orderList) {
            order.execute();
        }
        orderList.clear();
    }
}
